// 1. 导入定义验证规则的模块
const joi = require('joi')

// 2. 定义验证规则
const news_id = joi.number().integer().min(1).required()
const news_title = joi.string().required()
const post_time = joi.date().required()
const news_img = joi.string().min(5).required()
const news_link = joi.string().min(5).required()
const img_original_name = joi.string().allow(null, '')
const news_summary = joi.string().allow(null, '')
const hits = joi.number().integer().allow(null, '')
const _id = joi.string().alphanum().required()


// 3. 向外共享验证规则对象
exports.add_news_schema = {
    body: {news_id, news_title, post_time, news_img, news_link, img_original_name, news_summary, hits}
}

exports.update_news_schema = {
    body: {_id, news_id, news_title, post_time, news_img, news_link, img_original_name, news_summary, hits}
}